package com.ruoyi.mng.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mng.domain.HzMerBalanceLog;
import com.ruoyi.mng.service.IHzMerBalanceLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商户额度变更日志Controller
 * 
 * @author chenqiang
 * @date 2023-04-28
 */
@Controller
@RequestMapping("/mng/balancelog")
public class HzMerBalanceLogController extends BaseController
{
    private String prefix = "mng/balancelog";

    @Autowired
    private IHzMerBalanceLogService hzMerBalanceLogService;

    @RequiresPermissions("mng:balancelog:view")
    @GetMapping()
    public String balancelog()
    {
        return prefix + "/balancelog";
    }

    /**
     * 查询商户额度变更日志列表
     */
    @RequiresPermissions("mng:balancelog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HzMerBalanceLog hzMerBalanceLog)
    {
        startPage();
        List<HzMerBalanceLog> list = hzMerBalanceLogService.selectHzMerBalanceLogList(hzMerBalanceLog);
        return getDataTable(list);
    }

    /**
     * 导出商户额度变更日志列表
     */
    @RequiresPermissions("mng:balancelog:export")
    @Log(title = "商户额度变更日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HzMerBalanceLog hzMerBalanceLog)
    {
        List<HzMerBalanceLog> list = hzMerBalanceLogService.selectHzMerBalanceLogList(hzMerBalanceLog);
        ExcelUtil<HzMerBalanceLog> util = new ExcelUtil<HzMerBalanceLog>(HzMerBalanceLog.class);
        return util.exportExcel(list, "商户额度变更日志数据");
    }

    /**
     * 新增商户额度变更日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商户额度变更日志
     */
    @RequiresPermissions("mng:balancelog:add")
    @Log(title = "商户额度变更日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(HzMerBalanceLog hzMerBalanceLog)
    {
        return toAjax(hzMerBalanceLogService.insertHzMerBalanceLog(hzMerBalanceLog));
    }

    /**
     * 修改商户额度变更日志
     */
    @RequiresPermissions("mng:balancelog:edit")
    @GetMapping("/edit/{logId}")
    public String edit(@PathVariable("logId") Long logId, ModelMap mmap)
    {
        HzMerBalanceLog hzMerBalanceLog = hzMerBalanceLogService.selectHzMerBalanceLogByLogId(logId);
        mmap.put("hzMerBalanceLog", hzMerBalanceLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存商户额度变更日志
     */
    @RequiresPermissions("mng:balancelog:edit")
    @Log(title = "商户额度变更日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(HzMerBalanceLog hzMerBalanceLog)
    {
        return toAjax(hzMerBalanceLogService.updateHzMerBalanceLog(hzMerBalanceLog));
    }

    /**
     * 删除商户额度变更日志
     */
    @RequiresPermissions("mng:balancelog:remove")
    @Log(title = "商户额度变更日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(hzMerBalanceLogService.deleteHzMerBalanceLogByLogIds(ids));
    }
}
